package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;
import com.lagou.edu.mvcframework.pojo.ModalAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@LagouController
@LagouRequestMapping("/demo")
//@Security(value = {"wxx","szx"})
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;
    /**
     * 验证用户权限的控制器
     */
    @Security(value = {"wxx","szx"})
    @LagouRequestMapping("/handle01")
    public ModalAndView securityLogin(HttpServletRequest request, HttpServletResponse response,String username){
        System.out.println(":::::成功跳转控制器");
        ModalAndView modalAndView=new ModalAndView();
        modalAndView.setView("success");
        Map modalMap=new HashMap();
        modalMap.put("currentuser",username);
        modalAndView.setModelMap(modalMap);
        return modalAndView;
    }
    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }
}
